package com.taobao.handler;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import com.taobao.pojo.Line;
import com.taobao.pojo.Smaller;

public class SmallerHandler extends Handler {

    @SuppressWarnings("unchecked")
    public void handler(Line line) throws Exception {
        String value = line.getValue().trim();
        StringTokenizer st = new StringTokenizer(value, ",");
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < 3; i++) {
            list.add("");
        }
        int i = 0;
        while(st.hasMoreElements()){
            list.set(i, (String) st.nextElement());
            ++i;
        }
        if(list.size() != 3){
            list.set(1, "");
            list.set(2, "");
        }
        Smaller smaller = new Smaller(1, line.getKey(), Integer.parseInt(list.get(0)), list.get(1), list.get(2));
        List<Smaller> smallers = (List<Smaller>) getObj1();
        smallers.add(smaller);
    }
}
